worker_processes  8;

#error_log   logs/error.log;


pid        /data/br/base/nginx/conf/nginx.pid;
worker_rlimit_nofile 65535;
daemon off;

events {
    use epoll;
    worker_connections  204800;
}

http {

    #access_log off;   #关闭日志功能

#调整前
##    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
##                      '$status $content_length  $body_bytes_sent "$http_referer" '
##                      '"$http_user_agent" "$http_x_forwarded_for"';
##调整后（增加后端服务器IP、响应时间）20201117
     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                       '$status  $content_length  $body_bytes_sent "$http_referer" '
                       '"$http_user_agent" "$http_x_forwarded_for"'
                       '"$upstream_addr" "$request_time" "$upstream_response_time"';


    #根据http status状态记录访问日志到不同文件
    map $status $normal {
        ~^[23]  1;
        default 0;
         }

     map $status $abnormal {
        ~^[23]  0;
        default 1;
        }
    fastcgi_intercept_errors on;

    server_tokens off;                                #隐藏版本号 （1.8 以前放到http里面）
    include       mime.types;
    charset UTF-8;
    default_type  application/octet-stream;


    client_max_body_size 2000M;

    #用于tomcat反向代理,解决nginx 504错误
       proxy_connect_timeout   300s;
       proxy_send_timeout      300s;
       proxy_read_timeout      300s;
       proxy_buffer_size       512k;
       proxy_buffers           16 512k;
       proxy_busy_buffers_size 512k;
       proxy_temp_file_write_size 512k;
    # 以timeout结尾配置项时间要配置大点
    # fastcgi优化
       fastcgi_connect_timeout 300s;    #连接到后端fastcgi超时时间
       fastcgi_send_timeout 300s;       #向fastcgi请求超时时间(这个指定值已经完成两次握手后向fastcgi传送请求的超时时间)
       fastcgi_read_timeout 300s;       #指定接收FastCGI应答的超时时间，这个值是已经完成两次握手后接收FastCGI应答的超时时间

    sendfile        on;
    tcp_nopush on; #防止网络阻塞
    tcp_nodelay on; #防止网络阻塞
    keepalive_timeout 90; #长连接超时时间，单位是秒
    #send_timeout 60;
    #代理服务端不要主要主动关闭客户端连接,解决Nginx 499错误
    proxy_ignore_client_abort on;

    gzip off;


    # 包含所有域名的配置文件
  include   vhosts/*.conf;
}